# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=mkvtoolnix
pkgver=88.0
pkgrel=0
pkgdesc="Set of tools to create, edit and inspect Matroska files"
url="https://mkvtoolnix.download/index.html"
# riscv64 blocked by fatal error: boost/core/use_default.hpp: No such file or directory
arch="all !riscv64"
license="GPL-2.0-only"
makedepends="
	boost-dev
	cmark-dev
	docbook-xsl
	file-dev
	flac-dev
	fmt-dev
	gmp-dev
	gtest-dev
	libmatroska-dev
	libogg-dev
	libvorbis-dev
	nlohmann-json
	pcre2-dev
	pugixml-dev
	qt6-qtbase-dev
	qt6-qtmultimedia-dev
	qt6-qtsvg
	ruby
	ruby-rake
	zlib-dev
	"
subpackages="$pkgname-doc $pkgname-gui"
source="https://mkvtoolnix.download/sources/mkvtoolnix-$pkgver.tar.xz"

build() {
	export CFLAGS="$CFLAGS -flto=auto"
	export CXXFLAGS="$CXXFLAGS -flto=auto"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--without-gettext \
		--disable-update-check
	rake V=1 -j$JOBS
}

check() {
	rake V=1 -j$JOBS tests:unit
	rake V=1 -j$JOBS tests:run_unit
}

package() {
	rake DESTDIR="$pkgdir" install
}

gui() {
	pkgdesc="$pkgdesc (GUI)"
	depends="$pkgname qt6-qtsvg"

	amove usr/bin/mkvtoolnix-gui
	amove usr/share
}

sha512sums="
b1b08a42f55e841c618cbfe19f40310ea7c879d43a6a1db4152abfd5618deccc33332a73b1fc21757660891907b9eb12028b8c016134708f0464d5cc10a343c2  mkvtoolnix-88.0.tar.xz
"
